package com.lzq.leetcode.hoot100;

import com.lzq.leetcode.hoot100.ds.ListNode;

public class s206 {
    public static void main(String[] args) {
        ListNode head = new ListNode(new int[]{1, 2, 3, 4, 5});
        ListNode rev = new s206().reverseList(head);
        System.out.println(rev);
    }

    public ListNode reverseList(ListNode head) {
        if (head == null || head.next == null) {
            return head;
        }
        ListNode newHead = reverseList(head.next);
        head.next.next = head;
        head.next = null;
        return newHead;

    }
}
